package com.oa.tools.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static String date2Str(Date date) {
		return sdf.format(date);
	}
	
	public static String date2Str(Long timeMill) {
		return sdf.format(new Date(timeMill));
	}

	public static String date2Str(Date date, String pattern) {
		SimpleDateFormat sdf1 = new SimpleDateFormat(pattern);
		return sdf1.format(date);
	}

	public static Date str2Date(String dateStr) {
		try {
			return sdf.parse(dateStr);
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static String curDayStr() {
		return date2Str(new Date(),"yyyyMMdd");
	}
}